package com.thinkgem.jeesite.common.utils;

import java.util.Random;

/**
 *
 * 随机数生成工具
 * Created by liu_pc on 2015-11-10.
 */
public class RandomNumUtiles {

    /**
     * 随机数生成工具
     * @param length
     * @return
     */
    public static String getRandomNum(int length) { //length表示生成字符串的长度
        String base = "01234567890";
        Random random = new Random();
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < length; i++) {
            int number = random.nextInt(base.length());
            sb.append(base.charAt(number));
        }

        return sb.toString();
    }
}
